package cn.com.unionlife.hy.system.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.com.unionlife.hy.core.controller.BaseController;
import cn.com.unionlife.hy.core.exception.BusinessException;
import cn.com.unionlife.hy.system.service.MenuQryService;
import cn.com.unionlife.hy.system.vo.MenuVO;
import cn.com.unionlife.hy.system.vo.UserVO;

@Controller("homeController")
public class HomeController extends BaseController {
	
	@Resource
	private MenuQryService menuQryService;

	@RequestMapping("home")
	public String goHome(HttpServletRequest request , Model model) throws BusinessException{
		UserVO loginedUser = getLoginedUser(request);
		if(loginedUser != null){
			List<MenuVO> menus = menuQryService.getUserMenu(loginedUser.getUm_user_id());
			model.addAttribute("menus", menus);
			model.addAttribute("user", loginedUser);
		}else{
			return "redirect:/login";
		}
		return "system/home";
	}
}
